import 'dart:convert';


import 'package:flutter/services.dart' show rootBundle;

import '../utils/log_util.dart';


class Global {

  static String APP_NAME = '';
  static String baseUrl = '';
  static String baseUrlTest = '';
  static String CHANNEL = 'APP001'; // 应用商店的标识

  static bool isAuditing = false; // 是否在审核

  static init() async {
    /// 一定要先运行项目根目录下的 config.sh 将 config.json 拷贝到 assets 下
    /// Unable to load asset: "assets/config.json".  记得 pub.get
    String configStr = await rootBundle.loadString('assets/config.json');
    var configJson = jsonDecode(configStr);

    APP_NAME = configJson['app_name'];
    baseUrl = configJson['base_url'];
    baseUrlTest = configJson['base_url_test'];
    LogUtil.isLogEnable = configJson['log_enable']; // 是否开启日志打印
  }

  // 用户协议
  static String agreementUserTitle = "用户协议";
  static String getAgreementUser(){
    return "https://api.rentianjf.com/protocol/agreement.html?name=${Uri.encodeFull(APP_NAME)}&corporate=${Uri.encodeFull('重庆两江新区宝升小额贷款股份有限公司')}";
  }
  // 隐私政策
  static String agreementPolicyTitle = "隐私保护政策";
  static String getAgreementPolicy()  {
    return "https://h5.rentianjf.com/protocol/app-privacy.html?name=${Uri.encodeFull(APP_NAME)}&corporate=${Uri.encodeFull('重庆两江新区宝升小额贷款股份有限公司')}";
  }
  // 注销协议
  static String agreementCancelTitle = "账号注销协议";
  static String getAgreementCancel()  {
    return "https://api.rentianjf.com/protocol/cancel.html?name=${Uri.encodeFull(APP_NAME)}&corporate=${Uri.encodeFull('重庆两江新区宝升小额贷款股份有限公司')}";
  }
}